import axios from "@/api/config"
import {baseURL} from "@/api/ipconfig"
var ip = baseURL.URL2
var ip2 = baseURL.URL1
// 消息类型 开始=======

export const messageType = {
  list: data => axios.post('/message/management/msg/type/page', data),

  add: data => axios.post('/message/management/msg/type/add', data),

  edit: data => axios.post('/message/management/msg/type/update', data),

  delete: async (data) => { //消息类型删除
    const url = '/message/management/msg/type/delete/' + data;
    let res = await axios.delete(url);
    return res;
  },
  detail: async (data) => { //消息类型详情
    const url = '/message/management/msg/type/' + data;
    let res = await axios.get(url);
    return res;
  }
}

//消息类型 结束=======

//消息模板 开始=======
export const messageTemplate = {
  list: data => axios.post(ip+'/msg/template/list', data), //获取消息模板列表
  updateState: data => axios.post(ip+'/msg/template/disable/' + data.id + '/' + data.state), //更新消息模板状态
  config: data => axios.post(ip+'/msg/template/config', data), //设置消息模板
  detail: async (data) => { //消息模板详情
    const url = ip+'/msg/template/' + data;
    let res = await axios.get(url);
    return res;
  },
  getALLmessage: data => axios.post(ip+'/message/management/msg/type/list', data), //获取所有的消息类型

}

// 即时消息 开始
export const instantMsg = {
  list: data => axios.post(ip2+'/system/page', data), //获取消息列表
  add: data => axios.post(ip2+'/system', data),
  update: data => axios.put(ip2+'/system', data),
  remove: async (data) => {
    const url =ip2+'/system/logic';
    let res = await axios.delete(url, {
      data
    });
    return res;
  },
  detail: async (data) => { //消息详情
    const url = ip2+'/system/one/' + data;
    let res = await axios.get(url);
    return res;
  }
}
// 即时消息 结束